package hot100;

public class climbStairs {
    public int climbStairs(int n) {
        //爬一层楼
        int q1 = 1;
        //爬二层楼
        int q2 = 2;

        if(n == 1) {
            return q1;
        }else if(n == 2) {
            return q2;
        }else {
            int r = 0;
            for(int i = 3;i <= n;i++) {
                //当前爬法等于前两次之和
                r = q1 + q2;
                q1 = q2;
                q2 = r;
            }
            return r;
        }

    }
}
